Date Class
A Date object stores the number of seconds since 12:00AM, January 1, 1904. Properties of a Date enable you to get and set a day value only, a date/time, or only a time.
More information available in parent classes: Object
Notes
When you create and instantiate a Date object, it is initialized to the current date and time. If you try to set the date or date/time and the format is incorrect, REALbasic will raise an UnsupportedFormatException.
The date properties of FolderItems can be accessed via the CreationDate and ModificationDate properties of FolderItem objects. You can get the current date and time by creating a new date and reading the values of the Year, Month, Day, Hour, Minute, and Second properties.
In the following code:
What is actually happening is that the Variant stores the value of the TotalSeconds property as a Double, along with the type information that it is a Date (the Variant's Type property = 7).
Although Date is a class that is subclassed from Object, VarType identifies a Date as a Date data type (Type=7) rather than an Object (Type=9).
Use the ParseDate function to convert a date string to a Date value.
The TotalSeconds property is the 'master' property that stores the date/time associated with a Date. The other property values are derived from TotalSeconds. If you change the value of the TotalSeconds property, the values of the Year, Month, Day, Hour, Minute, and Second properties change to reflect the second on which TotalSeconds occurs. Conversely, if you change any of these properties, the value of TotalSeconds changes commensurately.
The Date properties that return formatted date or time information are affected by the user's operating system settings. If you need to control the exact appearance of date/time information, the best way is to extract the information yourself and manage the formatting using String manipulation functions.
Examples
This example creates a Date and displays the current date in a message box.
You can write this more compactly by instantiating the Date variable within the Dim statement, as in this example:
This example sets a Date object to 10 February 1954.
See Also
Microseconds, ParseDate, Ticks, functions; FolderItem class.